Micron Document
<!DOCTYPE html>
<html class="client-nojs vector-feature-night-mode-disabled vector-feature-language-in-header-enabled vector-feature-language-in-main-page-header-disabled vector-feature-page-tools-pinned-disabled vector-feature-toc-pinned-clientpref-1 vector-feature-main-menu-pinned-disabled vector-feature-limited-width-clientpref-1 vector-feature-limited-width-content-enabled vector-feature-custom-font-size-clientpref-1 vector-feature-appearance-pinned-clientpref-1 vector-sticky-header-enabled" lang="en" dir="ltr"><head>
<meta charset="UTF-8">
<title>Marzullo's algorithm</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="canonical" href="https://en.wikipedia.org/wiki/Marzullo's_algorithm"> <link href="./mw/skins.vector.icons.css" rel="stylesheet" type="text/css">
<link href="./mw/skins.vector.search.codex.styles.css" rel="stylesheet" type="text/css">
<link href="./mw/skins.vector.styles.css" rel="stylesheet" type="text/css">
<link href="./mw/user.styles.css" rel="stylesheet" type="text/css">
<meta name="ResourceLoaderDynamicStyles" content="">
<link rel="stylesheet" type="text/css" href="./mw/site.styles.css">
<link rel="stylesheet" type="text/css" href="./mw/noscript.css">
<link rel="stylesheet" type="text/css" href="./footer.css">
<link rel="stylesheet" type="text/css" href="./vector-2022.css">
</head>
<body class="skin--responsive skin-vector skin-vector-search-vue mediawiki ltr sitedir-ltr mw-hide-empty-elt ns-0 ns-subject page-Marzullo_s_algorithm rootpage-Marzullo_s_algorithm skin-vector-2022 action-view">
<div class="mw-page-container">
<div class="mw-page-container-inner">
<div class="mw-content-container">
<main id="content" class="mw-body">
<header class="mw-body-header vector-page-titlebar">
<h1 id="firstHeading" class="firstHeading mw-first-heading">
<span id="openzim-page-title" class="mw-page-title-main"><span class="mw-page-title-main">Marzullo's algorithm</span></span>
</h1>
</header>
<a id="top"></a>
<div id="bodyContent" class="vector-body ve-init-mw-desktopArticleTarget-targetContainer" aria-labelledby="firstHeading" data-mw-ve-target-container="">
<div id="mw-content-text" class="mw-body-content mw-content-ltr" lang="en" dir="ltr"><div class="mw-content-ltr mw-parser-output" lang="en" dir="ltr">
<p><b>Marzullo's algorithm</b>, invented by <a href="Keith_Marzullo" title="Keith Marzullo">Keith Marzullo</a> for his Ph.D. dissertation in 1984, is an <i>agreement algorithm</i> used to select sources for estimating accurate time from a number of <a href="Noise" title="Noise">noisy</a> time sources. A refined version of it, renamed the "<a href="Intersection_algorithm" title="Intersection algorithm">intersection algorithm</a>", forms part of the modern <a href="Network_Time_Protocol" title="Network Time Protocol">Network Time Protocol</a>.
Marzullo's algorithm is also used to compute the <a href="Relaxed_intersection" title="Relaxed intersection">relaxed intersection</a> of n boxes (or more generally <i>n</i> subsets of <b>R</b><sup><i>n</i></sup>), as required by several <a href="Set_estimation" title="Set estimation">robust set estimation</a> methods.
</p>
<meta property="mw:PageProp/toc">
<div class="mw-heading mw-heading2"><h2 id="Purpose">Purpose</h2></div>
<p>Marzullo's algorithm is efficient in terms of time for producing an optimal value from a set of estimates with <a href="Confidence_interval" title="Confidence interval">confidence intervals</a> where the actual value may be outside the confidence interval for some sources. In this case the best estimate is taken to be the smallest interval <a href="Consistent" class="mw-redirect" title="Consistent">consistent</a> with the largest number of sources.
</p><p>If we have the estimates 10&nbsp;±&nbsp;2, 12&nbsp;±&nbsp;1 and 11&nbsp;±&nbsp;1 then these intervals are [8,12], [11,13] and [10,12] which intersect to form [11,12] or 11.5&nbsp;±&nbsp;0.5 as consistent with all three values.
</p>

<p>If instead the ranges are [8,12], [11,13] and [14,15] then there is no interval consistent with all these values but [11,12] is consistent with the largest number of sources — namely, two of them.
</p>

<p>Finally, if the ranges are [8,9], [8,12] and [10,12] then both the intervals [8,9] and [10,12] are consistent with the largest number of sources.
</p>

<p>This procedure determines an interval. If the desired result is a best value from that interval then a naive approach would be to take the center of the interval as the value, which is what was specified in the original Marzullo algorithm. A more sophisticated approach would recognize that this could be throwing away useful information from the confidence intervals of the sources and that a <a href="Probabilistic_model" class="mw-redirect" title="Probabilistic model">probabilistic model</a> of the sources could return a value other than the center.
</p><p>Note that the computed value is probably better described as "optimistic" rather than "optimal". For example, consider three intervals [10,12], [11, 13] and [11.99,13]. The algorithm described below computes [11.99, 12] or 11.995&nbsp;±&nbsp;0.005 which is a very precise value. If we suspect that one of the estimates might be incorrect, then at least two of the estimates must be correct. Under this condition, the best estimate is [11,13] since this is the largest interval that always intersects at least two estimates. The algorithm described below is easily parameterized with the maximum number of incorrect estimates.
</p>
<div class="mw-heading mw-heading2"><h2 id="Method">Method</h2></div>
<p>Marzullo's algorithm begins by preparing a table of the sources, sorting it and then searching (efficiently) for the intersections of intervals. For each source there is a range [c−r,c+r] defined by c&nbsp;±&nbsp;r. For each range the table will have two <a href="Tuple" title="Tuple">tuples</a> of the form <span class="nowrap">⟨offset,type⟩</span>. One tuple will represent the beginning of the range, marked with type −1 as <span class="nowrap">⟨c−r,−1⟩</span> and the other will represent the end with type +1 as <span class="nowrap">⟨c+r,+1⟩</span>.
</p><p>The description of the algorithm uses the following variables: best (largest number of overlapping intervals found), cnt (current number of overlapping intervals), beststart and bestend (the beginning and end of best interval found so far), i (an index), and the table of tuples.
</p>
<ol><li value="0">Build the table of tuples.</li>
<li><a href="Sorting_algorithm" title="Sorting algorithm">Sort</a> the table by the offset. (If two tuples with the same offset but opposite types exist, indicating that one interval ends just as another begins, then a method of deciding which comes first is necessary. Such an occurrence can be considered an overlap with no duration, which can be found by the algorithm by putting type −1 before type +1. If such pathological overlaps are considered objectionable they can be avoided by putting type +1 before −1 in this case.)</li>
<li>[initialize] best=0 cnt=0</li>
<li>[loop] go through each tuple in the table in ascending order</li></ol>
<dl><dd><ol><li value="4">[current number of overlapping intervals] cnt=cnt−type[i]</li>
<li>if cnt&gt;best then best=cnt beststart=offset[i] bestend=offset[i+1]</li></ol></dd></dl>
<dl><dd><i>commentary: the next tuple, at [i+1], will either be an end of an interval (type=+1) in which case it ends this best interval, or it will be a beginning of an interval (type=−1) and in the next step will replace best.</i></dd></dl>
<dl><dd><i>ambiguity: unspecified is what to do if best=cnt. This is a condition of a tie for greatest overlap. The decision can either be made to take the smaller of bestend−beststart and offset[i+1]−offset[i] or just take an arbitrary one of the two equally good entries. This decision is relevant only when type[i+1]=+1.</i></dd></dl>
<ol><li value="6">[end loop] return [beststart,bestend] as optimal interval. The number of <i>false</i> sources (ones which do not overlap the optimal interval returned) is the number of sources minus the value of best.</li></ol>
<div class="mw-heading mw-heading2"><h2 id="Efficiency">Efficiency</h2></div>
<p>Marzullo's algorithm is efficient in both space and time. The <a href="Asymptotic" class="mw-redirect" title="Asymptotic">asymptotic</a> space usage is <a href="Big_O_notation" title="Big O notation">O(n)</a>, where n is the number of sources. In considering the asymptotic time requirement the algorithm can be considered to consist of building the table, sorting it and searching it. Sorting can be done in O(n log n) time, and this dominates the building and searching phases which can be performed in <a href="Linear" class="mw-redirect" title="Linear">linear</a> time. Therefore, the time efficiency of Marzullo's algorithm is <a href="Big_O_notation" title="Big O notation">O(n log n)</a>.
</p><p>Once the table has been built and sorted it is possible to update the interval for one source (when new information is received) in linear time. Therefore, updating data for one source and finding the best interval can be done in O(n) time.
</p>
<div class="mw-heading mw-heading2"><h2 id="References">References</h2></div>
<ul><li><style data-mw-deduplicate="TemplateStyles:r1238218222">
/* start https://en.wikipedia.org/ */


.mw-parser-output cite.citation{font-style:inherit;word-wrap:break-word}.mw-parser-output .citation q{quotes:"\"""\"""'""'"}.mw-parser-output .citation:target{background-color:rgba(0,127,255,0.133)}.mw-parser-output .id-lock-free.id-lock-free a{background:url("./mw/Lock-green.svg")right 0.1em center/9px no-repeat}.mw-parser-output .id-lock-limited.id-lock-limited a,.mw-parser-output .id-lock-registration.id-lock-registration a{background:url("./mw/Lock-gray-alt-2.svg")right 0.1em center/9px no-repeat}.mw-parser-output .id-lock-subscription.id-lock-subscription a{background:url("./mw/Lock-red-alt-2.svg")right 0.1em center/9px no-repeat}.mw-parser-output .cs1-ws-icon a{background:url("./mw/Wikisource-logo.svg")right 0.1em center/12px no-repeat}body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-free a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-limited a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-registration a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-subscription a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .cs1-ws-icon a{background-size:contain;padding:0 1em 0 0}.mw-parser-output .cs1-code{color:inherit;background:inherit;border:none;padding:inherit}.mw-parser-output .cs1-hidden-error{display:none;color:var(--color-error,#d33)}.mw-parser-output .cs1-visible-error{color:var(--color-error,#d33)}.mw-parser-output .cs1-maint{display:none;color:#085;margin-left:0.3em}.mw-parser-output .cs1-kern-left{padding-left:0.2em}.mw-parser-output .cs1-kern-right{padding-right:0.2em}.mw-parser-output .citation .mw-selflink{font-weight:inherit}@media screen{.mw-parser-output .cs1-format{font-size:95%}html.skin-theme-clientpref-night .mw-parser-output .cs1-maint{color:#18911f}}@media screen and (prefers-color-scheme:dark){html.skin-theme-clientpref-os .mw-parser-output .cs1-maint{color:#18911f}}


/* end https://en.wikipedia.org/ */
</style><cite id="CITEREFMarzullo1984" class="citation thesis cs1">Marzullo, K. A. (Feb 1984). <a rel="nofollow" class="external text" href="https://searchworks.stanford.edu/view/1137192"><i>Maintaining the Time in a Distributed System: An Example of a Loosely-Coupled Distributed Service</i></a>. <i>Ph.D. dissertation</i> (Thesis). Department of Electrical Engineering. Stanford University. <a href="ASIN_(identifier)" class="mw-redirect" title="ASIN (identifier)">ASIN</a>&nbsp;<a rel="nofollow" class="external text" href="https://www.amazon.com/dp/B000710CSC">B000710CSC</a>. <a href="OCLC_(identifier)" class="mw-redirect" title="OCLC (identifier)">OCLC</a>&nbsp;<a rel="nofollow" class="external text" href="https://search.worldcat.org/oclc/38621764">38621764</a>. DDC 3781.1984 M.</cite></li></ul>
<div class="mw-heading mw-heading2"><h2 id="External_links">External links</h2></div>
<ul><li><cite id="CITEREFMills2000" class="citation web cs1">Mills, David L. (Aug 5, 2000). <a rel="nofollow" class="external text" href="http://www.eecis.udel.edu/~mills/database/papers/history.pdf">"A Brief History of NTP Time: Confessions of an Internet Timekeeper"</a> <span class="cs1-format">(PDF)</span>. <i>EECIS</i>. UDEL.</cite></li>
<li><cite class="citation web cs1"><a rel="nofollow" class="external text" href="http://www.cse.ucsd.edu/users/marzullo/">"Keith Marzullo"</a>. <i>CSE</i>. UCSD.</cite></li></ul></div><!--htdig_noindex--><div><div class="zim-footer">
This article is issued from <a class="external text" title="Last edited on 2024-12-10" href="https://en.wikipedia.org/wiki/?title=Marzullo's_algorithm&amp;oldid=1262253269">Wikipedia</a>. The text is available under <a class="external text" href="https://creativecommons.org/licenses/by-sa/4.0/deed.en">Creative Commons Attribution-Share Alike 4.0</a> unless otherwise noted. Additional terms may apply for the media files.
</div>
</div><!--/htdig_noindex--></div>
</div>
</main>
</div>
</div>
</div>

</body></html>